package com.biz.primus.app.rest.controller.member;

import com.biz.primus.app.rest.controller.base.RestBaseController;
import com.biz.primus.app.rest.feign.member.MemberFeignClient;
import com.biz.primus.base.support.rest.vo.JsonResult;
import com.biz.primus.base.global.GlobalParams;
import com.biz.primus.model.member.exception.UserExceptionResponse;
import com.biz.primus.model.member.exception.UserExceptionType;
import com.biz.primus.model.member.vo.MemberBankCardVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 会员银行卡相关Controller
 * @author jun.liu
 * @usage
 * @reviewer
 * @since 2017年11月3日
 */
@RestController
@RequestMapping("/users")
@Api(value = "会员银行卡模块接口文档")
public class BankCardController extends RestBaseController
{

    private final MemberFeignClient memberFeignClient;

    @Autowired
    public BankCardController(MemberFeignClient memberFeignClient) {
        this.memberFeignClient = memberFeignClient;
    }

    //********************************************
    //               银   行   卡
    //********************************************

    @ApiOperation(value = "根据用户id获取银行卡信息", response = MemberBankCardVo.class)
    @GetMapping("/bankcardinfo")
    @UserExceptionResponse({
            UserExceptionType.BANK_CARD_ID_NULL,UserExceptionType.BANK_CARD_NULL
    })
    public JsonResult bankcardinfo(@RequestBody GlobalParams reqVo)
    {
        MemberBankCardVo respVo = memberFeignClient.getBankcardInfo(reqVo);
        return new JsonResult(respVo);
    }

    @ApiOperation(value = "更新银行卡信息")
    @GetMapping("/updatebankcard")
    @UserExceptionResponse({
            UserExceptionType.PARAMS_ERROR,UserExceptionType.MEMBERID_NULL
    })
    public JsonResult updatebankcard(GlobalParams gp, @RequestBody MemberBankCardVo reqVo)
    {
        reqVo = buildRequest(gp, reqVo);
        memberFeignClient.updateBankcardInfo(reqVo);
        return new JsonResult();
    }

}
